package platformer;

import java.awt.Color;
import java.awt.Point;
import java.awt.geom.Ellipse2D;



@SuppressWarnings("serial")
public class Bullet extends Ellipse2D.Double implements Drawable
{
	
	double magnitude;
	double speed;
	double dX, dY;
	int ttl;
	
	Color color;
	Point dest;
	
	public Bullet(double x, double y, Point dest, Color color)
	{
		height = 8;
		width = 8;
		this.x = x - 4;
		this.y = y - 4;
		this.dest = dest;
		this.color = color;
		ttl = 180;
		speed = 15;
		dX = dest.x - x;
		dY = dest.y - y;
	}
	
	public void move()
	{
		magnitude = Math.sqrt( dX*dX + dY*dY );
		dX = dX / magnitude * speed;
		dY = dY / magnitude * speed;
		
		setFrame(x + dX, y + dY, width, height);
	}

	@Override
	public Color getColor()
	{
		return this.color;
	}
	
}